package javase.reflection.spies;

import java.lang.reflect.Field;

import javase.reflection.Specific;

public class FieldSpy {
	
	public static void main(String[] args) {
		FieldSpy spy = new FieldSpy();
		Object object = new Specific();
		spy.printPublicFields(object.getClass());
		spy.printDeclaredFields(object.getClass());
	}
	
	private void printPublicFields(Class<?> clazz) {
		System.out.println("getFields:");
		printFields(clazz.getFields());
	}
	
	private void printDeclaredFields(Class<?> clazz) {
		System.out.println("getDeclaredFields:");
		printFields(clazz.getDeclaredFields());
	}
	
	private void printFields(Field [] fields) {
		for (Field field : fields) {
			System.out.println(field.toGenericString());
		}
		System.out.println("");
	}
}
